const Koa=require('koa');
const cors=require('koa2-cors');
const router=require('koa-router')();
const app=new Koa();
let list=[
    {type:'坦克',hero:'阿古朵、蒙括...'},
    {type:'刺客',hero:'镜、马超...'},
    {type:'法师',hero:'西施、上官婉儿...'},
]
app.listen(3000,()=>{
    console.log(3000);
})
app.use(cors());
app.use(router.routes());
router.get('/data',async ctx=>{
    ctx.body=list;
})
router.get('/list:id',async ctx=>{
    let i = ctx.params.id;
    console.log(i);
    ctx.body=list[i]
})